:" 禁用VI兼容模式
set nocompatible

"设置backspace的工作方式： 
set backspace=indent,eol,start

" Vim 的内部编码
set encoding=utf-8

"Vim 在与屏幕/键盘交互时使用的编码(取决于实际的终端的设定)

set termencoding=utf-8

"Vim 当前编辑的文件在存储时的编码

set fileencoding=utf-8

"Vim 打开文件时的尝试使用的编码

set fileencodings=ucs-bom,utf-8,gbk,default,latin1

"设置中文帮助

set helplang=cn

"设置字体

if has("gui_running")

      set guifont=Powerline_Consolas:h13:cANSI:qDRAFT
      au GUIEnter * simalt ~x " 窗口启动时自动最大化
      set guioptions-=m " 隐藏菜单栏
      set guioptions-=T " 隐藏工具栏
      set guioptions-=L " 隐藏左侧滚动条
      set guioptions-=r " 隐藏右侧滚动条
      set guioptions-=b " 隐藏底部滚动条
      "set showtabline=0 " 隐藏Tab栏
      "set color schema

       "colorscheme herald
       "colorscheme molokai
       set background=dark
       colorscheme solarized
endif

"格式化高亮

syntax on

"显示行号

set nu 

"括号匹配

set showmatch 

"自动检测文件类型

filetype plugin indent on 

"在缩进和遇到 Tab 键时使用空格替代

set expandtab

"根据文件类型设置缩进格式

au FileType html,python,vim,javascript setl shiftwidth=2

au FileType html,python,vim,javascript setl tabstop=2

au FileType java,php setl shiftwidth=4

au FileType java,php setl tabstop=4

 

"启动vim时不要自动折叠代码

set foldlevel=100   

"自动对齐       

set ai    

"依据上面的对起格式

set si   

set smarttab

set wrap

set lbr

set tw=0

set foldmethod=syntax

" Turn backup off

set nobackup

set nowb

set noswapfile 

" Sets how many lines of history VIM har to remember

set history=400

" Set to auto read when a file is changed from the outside

set autoread

" The commandbar is 2 high

set cmdheight=1

" Change buffer - without saving

set hid
let mapleader=","


" 配置文件.vimrc更改后自动重新载入使设置生效
autocmd! bufwritepost _vimrc source %
set tags=tags;  " ; 不可省略，表示若当前目录中不存在tags， 则在父目录中寻找。
map <C-F12> :!ctags -R --fields=+aimS --languages=php<CR> 
"===========以下修改emmet 触发快捷键======
"let g:user_emmet_expandabbr_key = '<Tab>'

" ===============配置NERDTree-tags=========
" 关闭NERDTree快捷键
map <F12> :NERDTreeToggle<CR>
map <leader>k :NERDTreeTabsToggle<CR>
" 显示行号
let NERDTreeShowLineNumbers=1
let NERDTreeAutoCenter=1
let NERDTreeQuitOnOpen=1
" 是否显示隐藏文件
let NERDTreeShowHidden=1
" 设置宽度
let NERDTreeWinSize=31
" 在终端启动vim时，共享NERDTree
let g:nerdtree_tabs_open_on_console_startup=1
" 忽略一下文件的显示
let NERDTreeIgnore=['\.pyc','\~$','\.swp']
" 显示书签列表
let NERDTreeShowBookmarks=1
"===========================================
" 配置NERDTree-git-plugin插件
let g:NERDTreeShowIgnoredStatus = 1
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'

"-- Taglist setting --
map <leader>t :TlistToggle<CR>
"自动更新taglist
let Tlist_Auto_Update = 1
"选择函数后自动关闭
let Tlist_Close_On_Select = 1
"打开自动获得焦点
let Tlist_GainFocus_On_ToggleOpen = 1
"设置taglist宽度
let Tlist_WinWidth=40       
"因为我们放在环境变量里，所以可以直接执行
let Tlist_Ctags_Cmd='ctags' 
"让窗口显示在右边，0的话就是显示在左边
let Tlist_Use_Right_Window=1 
"让taglist可以同时展示多个文件的函数列表
let Tlist_Show_One_File=0 
"非当前文件，函数列表折叠隐藏
let Tlist_File_Fold_Auto_Close=1 
 "当taglist是最后一个分割窗口时，自动推出vim
let Tlist_Exit_OnlyWindow=1
"为1则即使标签列表窗口未打开，taglist仍然会在后台处理vim所打开文件的标签
let Tlist_Process_File_Always=1 
let Tlist_Inc_Winwidth=0

"----php-complete----
"let g:phpcomplete_mappings = {
"   \ 'jump_to_def': '<C-f>',
"   \ 'jump_to_def_split': '<C-r>',
"   \ 'jump_to_def_vsplit': '<C-v>',
"   \}
"----NERDCOMMENTER配置----
" 注释的时候自动加个空格, 强迫症必配
let g:NERDSpaceDelims=1
"airline 主题
let g:airline_theme="molokai"
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
"滚动条美化
noremap <silent> <c-u> :call smooth_scroll#up(&scroll, 0, 2)<CR>
noremap <silent> <c-d> :call smooth_scroll#down(&scroll, 0, 2)<CR>
noremap <silent> <c-b> :call smooth_scroll#up(&scroll*2, 0, 4)<CR>
noremap <silent> <c-f> :call smooth_scroll#down(&scroll*2, 0, 4)<CR>
"expand-region配置，使用v扩大选择范围，V缩小选择范围
vmap v <Plug>(expand_region_expand)
vmap V <Plug>(expand_region_shrink)

"buffline配置
let g:airline#extensions#tabline#buffer_idx_mode = 1
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>4 <Plug>AirlineSelectTab4
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9

" 插件安装
call plug#begin('E:\vim\vimfiles\pluggeds')
"符号自动补全
Plug 'Raimondi/delimitMate'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'bling/vim-bufferline'
"markdown 插件
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown'
"sound插件
Plug 'tpope/vim-surround'
"美化滚动插件
Plug 'terryma/vim-smooth-scroll'
"选择模式扩展插件
Plug 'terryma/vim-expand-region'
Plug 'junegunn/vim-easy-align'
"目录树插件
Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
Plug 'jistr/vim-nerdtree-tabs'
Plug 'Xuyuanp/nerdtree-git-plugin'
"ctags 和 taglist插件
Plug 'shawncplus/phpcomplete.vim'
Plug 'vim-scripts/taglist.vim'
"emmet-vim插件
Plug 'mattn/emmet-vim'
"自动注释插件
Plug 'scrooloose/nerdcommenter'
"phpcd
"Plug 'lvht/phpcd.vim', { 'for': 'php', 'do': 'composer install' }
call plug#end()
